use clap::{ArgAction, Parser, Subcommand};

mod utils;
mod gui;

use gui::x_file_app::XFileApp;

#[derive(Parser)]
#[command(
    author,
    version,
    about,
    long_about = None,
    propagate_version = true,
    arg_required_else_help(true)
)]

struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
enum Commands {
    Copy {
        #[arg(long, action = ArgAction::SetTrue)]
        silent: bool,

        #[arg(long)]
        source: String,

        #[arg(long)]
        target: String,
    },
    Remove {
        #[arg(long, action = ArgAction::SetTrue)]
        silent: bool,

        #[arg(long)]
        path: String,
    },
    CRLF2LF {
        path: String,
    }
}

fn main_cmd() {
    let args = Cli::parse();
    match args.command {
        Commands::Copy {
            #[warn(unused_variables)]
            silent,
            source,
            target,
        } => {
            if let Err(e) = utils::copy(&source, &target) {
                eprintln!("{:?}", e);
            }
        },
        Commands::Remove {
            #[warn(unused_variables)]
            silent,
            path,
        } => {
            if let Err(e) = utils::remove(&path) {
                eprintln!("{:?}", e);
            }
        },
        Commands::CRLF2LF {
            path,
        } => {
            if let Err(e) = utils::crlf2lf(&path) {
                eprintln!("{:?}", e);
            }
        },
    };
}

fn main_gui() {
    match XFileApp::run() {
        Ok(_) => {}
        Err(_) => {}
    };
}


fn main() {
    main_gui();
}

